//
//  OpenAndShopViewController.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/11/13.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "OpenAndShopViewController.h"
#import "SettingTableViewCell.h"
#import "PatrolListViewController.h"
#import "PatrolListViewController.h"
#import "CheckRecordViewController.h"
#import "GotoCheckViewController.h"
@interface OpenAndShopViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)TB_TableView *homeTableView;

@end

@implementation OpenAndShopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.homeTableView];
    // Do any additional setup after loading the view.
}


-(TB_TableView*)homeTableView
{
    if (!_homeTableView) {
        
        _homeTableView=[[TB_TableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];
        
        _homeTableView.delegate=self;
        
        _homeTableView.dataSource=self;
        
        _homeTableView.tableFooterView=[[UIView alloc]init];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"SettingTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        
    }
    
    return _homeTableView;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 2;
    
}


-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SettingTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    if (indexPath.row==0) {
     
        cell.TipLabel.text=@"商户";
        
        cell.IcoImageView.image=[UIImage imageNamed:@"PeopleWork"];
        
    }else{
        
        cell.TipLabel.text=@"开办方";
        
         cell.IcoImageView.image=[UIImage imageNamed:@"PeopleWork"];
        
    }
    
    return cell;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
     return 50*SCREEN_WIDTH/320.0;
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.pushType==0) {
        
        //检查记录
        
        if (indexPath.row==0) {
            
            
            JobListModel *list=[JobListModel new];
            
            CheckRecordViewController*ShopRecordVC=[CheckRecordViewController new];
            
            list.ptype=@"1";
            
            if ([self getUserType]==2) {
                
                //检查员
                ShopRecordVC.isdeleMore=YES;
                
                ShopRecordVC.isEdit=NO;
                
            }else{
                
                //管理员
                
                ShopRecordVC.isEdit=NO;
                
                ShopRecordVC.isdeleMore=NO;
                
            }
            
            ShopRecordVC.searchName=@"输入关键字";
            
            ShopRecordVC.isAutoLoding=YES;
           
            ShopRecordVC.title=@"商户检查列表";
            
            ShopRecordVC.Reqmodel=list;
            
            [self.navigationController pushViewController:ShopRecordVC animated:YES];
            
        }else{
            
            //开办方
            
            JobListModel *list=[JobListModel new];
            
            CheckRecordViewController*  OpenRecordVC=[CheckRecordViewController new];
            
            list.ptype=@"2";
            
            if ([self getUserType]==2) {
                
                //检查员
                OpenRecordVC.isdeleMore=YES;
                
                OpenRecordVC.isEdit=NO;
                
            }else{
                
                //管理员
                
                OpenRecordVC.isEdit=NO;
                
                OpenRecordVC.isdeleMore=NO;
                
            }
            
            OpenRecordVC.searchName=@"输入关键字";
            
             OpenRecordVC.isAutoLoding=YES;
            
           
            OpenRecordVC.title=@"开办方检查列表";
            
            OpenRecordVC.Reqmodel=list;
            
           
            
           [self.navigationController pushViewController:OpenRecordVC animated:YES];
            
        }
        
       
        
        
    }else if (self.pushType==1)
    {
        JobListModel *list=[JobListModel new];
        
        PatrolListViewController *Patro=[PatrolListViewController new];
    
        Patro.isEdit=YES;
            
        Patro.isdeleMore=YES;
        
        Patro.isGroupStyle=YES;

        list.ptype=[NSString stringWithFormat:@"%ld",indexPath.row+1];
    
        Patro.Reqmodel=list;
        
        Patro.searchName=@"输入日志";
        Patro.AddBtnTitle=@"新增日志";
        Patro.title=@"检查日志";
        [self.navigationController pushViewController:Patro animated:YES];
  
    }else if (self.pushType==2)
    {
            GotoCheckViewController *GotoCheckNew=[GotoCheckViewController new];
        
            GotoCheckNew.userType=1;//检查类型
        
            GotoCheckNew.Checktype=indexPath.row;
        
            [self.navigationController pushViewController:GotoCheckNew animated:YES];
        
    }
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
